#自动取款机的存取款模拟效果

#存放账号信息的列表
account = [
			{"name":"zhangsan","password":"123456","money":1000},
			{"name":"lisi","password":"234567","money":2000},
			{"name":"wangwu","password":"345678","money":3000},
			{"name":"zhaoliu","password":"456789","money":4000},
          ]

#登陆界面
while True:
	print("="*40)
	print("{0:1} {1:11} {2:13}".format(" ","1.登陆账户","2.退出"))
	print("="*40)
	key=input("请输入您要执行的操作编号:")
	if key == '1':
		accountname=input("请输入你要登陆的账号:")
		for i in range(len(account)):
			if accountname == account[i]["name"]:
				Myaccount = account[i]
				break
		if len(Myaccount) > 0:
			accountpassword=input("请输入账号密码:")
			if accountpassword == Myaccount["password"]:
				break
			else:
				print("输入密码错误,请确认后再输入!")	
		else:
			print("没有您输入的账号信息,请核对后再输入!")
		input("按回车键继续:")
	elif key == '2':
		print("="*10,"您即将退出本系统,再见!","="*10)
		input("按回车键继续:")
		break
	else:
		print("输入的是无效值,请重新输入!")
		input("按回车键继续:")	

#账户操作界面
if len(Myaccount) > 0: #判断已获得了对应的账户信息
	while True:
		print("="*40)
		print("{0:1} {1:11} {2:13}".format(" ","1.查询余额","2.取钱"))
		print("{0:1} {1:13} {2:13}".format(" ","3.存钱","4.退出"))
		print("="*40)
		key=input("请输入您要执行的操作编号:")
		if key == '1':
			print("="*10,"查询余额","="*10)
			print("您的余额为:",Myaccount["money"])
			input("按回车键继续:")
		elif key == '2':
			print("="*10,"取钱","="*10)
			output_money = int(input("请输入您要取出的金额:"))#强制转换为int
			if output_money > Myaccount["money"]:#判断提取金额大于余额
				print("您的账户余额不足!")
			else:
				Myaccount["money"] -= output_money
				print("已为您将钱取出\n您的账户余额为:",Myaccount["money"])
			input("按回车键继续:")
		elif key == '3':
			print("="*10,"存钱","="*10)
			input_money = int(input("请输入您要存储的金额:"))
			Myaccount["money"] += input_money
			print("您的余额为:",Myaccount["money"])
			input("按回车键继续:")
		elif key == '4':
			print("="*10,"您即将退出本系统,再见!","="*10)
			input("按回车键继续:")
			break
		else:
			print("输入的是无效值,请重新输入!")
			input("按回车键继续:")
		
